import Cookies from 'js-cookie'
import store from '../store'

const TokenKey = 'Admin-Token'

export function getToken () {
  // 打包后的文件运行时无法操作cookie导致无法拿到token 故直接返回store中的token
  if (store) {
    return Cookies.get(TokenKey) || store.state.user.token
  } else {
    return Cookies.get(TokenKey)
  }
  // return 'admin'
}

export function setToken (token) {
  console.log(token)
  return Cookies.set(TokenKey, token)
}

export function removeToken () {
  return Cookies.remove(TokenKey)
}
